import request from '@/utils/request'
import { AxiosPromise } from 'axios'


enum Api {
  list = '/coupon/list',
  remove = '/coupon/remove',
  batchRemove = '/coupon/batchRemove',
  add = '/coupon/add',
  edit = '/coupon/edit',
  detail = '/coupon/detail',
}

// 获取列表
export const list = (data): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 删除
export const remove = (data: string) => {
  return request({
    url: Api.remove,
    method: 'post',
    data,
  })
}
// 批量删除
export const batchRemove = (data: (string | number)[]) => {
  return request({
    url: Api.batchRemove,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const save = (data: any) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 详情
export const detail = (data: any) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}
